<script setup>
import { onMounted, onUnmounted } from 'vue'

// 钩子函数 created mounted destroyed
console.log('发请求了.....')

onMounted(() => {
  // 回调函数会在组件渲染完执行  相当于之前的mounted
  console.log(document.querySelector('#box'))
})

onUnmounted(() => {
  // 组件卸载时执行(路由切换)
  console.log('组件卸载了')
})
</script>

<template>
  <div id="box">123</div>
</template>
